package br.com.sgdee.util;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class DateUtil {

	private static SimpleDateFormat format = null;
	
	static {
		format = new SimpleDateFormat();
	}
	
	/**
	 * 
	 * @param pattern
	 * @return
	 */
	public static String retornarDataFormatada(String pattern) {
		
		Date date = new Date();
		format.applyPattern(pattern);
		
		return format.format(date);
	}
	
	/**
	 * 
	 * 
	 * @param pattern
	 * @param date
	 * @return
	 */
	public static String retornarDataFormatada(String pattern, Date date) {
		
		format.applyPattern(pattern);
		
		return format.format(date);
	}
	
	/**
	 * 
	 * @param date
	 * @return
	 */
	public static Calendar recuperarCalendarPorData(Date date) {
		
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		
		return calendar;
	}
	
	/**
	 * 
	 * @param date
	 * @return
	 */
	public static Calendar recuperarCalendarPorDataAtual() {
		
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(new Date());
		
		return calendar;
	}
}
